package messaging;

import java.io.Serializable;

import remote.FutureMessage;
import remote.RemoteDistributedHashMap;
import remote.RemoteFuture;
/**
 * 
 * @author Team4
 * @version Spring 2013
 *
 */
@SuppressWarnings("serial")
public class InterNodeMessage implements Serializable
{
  /**
   * the original source node.
   */
  private int my_originalsource_node;
  /**
   * original destination.
   */
  private int my_originaldest_node;
  /**
   * the current source node.
   */
  private int my_source_node;
  /**
   * the current destination node number.
   */
  private int my_dest_node;
  /**
   * The method get/put/remove/addNode/removeNode.
   * get - 1
   * put - 2
   * remove - 3
   * automatic-re-balance trigger - 4
   * removeNode - 5
   * addNode - 6
   * tokenMessage - 7
   * fault tolerance data - 8
   * re-balance updates(data transfers) - 9
   */
  private int method_name;
  /**
   * The status of message.
   */
  private boolean answer_set;
  
  /**
   * Remove node message.
   */
  private boolean my_remove_message;
  /**
   * Stores the token packet.
   */
  private TokenPacket my_token_packet;  
  /**
   * Stores the remove node's command message.
   */
  private RemoveNodeMessage my_remove_node_message; 
  /**
   * Stores the add node message
   */
  private AddNodeMessage my_add_node_message;
  /**
   * hash table look up message.
   */
  private HashTableMessage my_hashTable_message;
  /**
   * Rebalance updates message for fault tolerance.
   */
  private RebalanceUpdates faulttolerance;
  /**
   * Constructor for the message
   */
  public InterNodeMessage
  (int ori_source, int ori_dest, int curr_source, int imm_dest, int method )
  {
    this.my_originalsource_node = ori_source;
    this.my_originaldest_node = ori_dest;
    this.my_source_node = curr_source;
    this.my_dest_node = imm_dest;
    this.method_name = method;
  }
  /**
   * set hash table message.
   */
  public void setHashTableMessage(final HashTableMessage my_hashmess)
  {
    this.my_hashTable_message = my_hashmess;
  }
  /**
   * get hash table message.
   * @return HashTableMessage
   * 
   */
  public HashTableMessage getHashTableMessage()
  {
    return this.my_hashTable_message;
  }
  /**
   * get the add node message.
   * @return
   */
  public AddNodeMessage get_AddNode_Message()
  {
    return my_add_node_message;
  }
  /**
   * sets the add node message.
   * @param addNodeMessage   
   */
  public void set_AddNode_Message(AddNodeMessage my_add_node_message)
  {
    this.my_add_node_message = my_add_node_message;
  }
  /**
   * gets the original source
   * @return int
   */
  public int getMy_originalsource_node()
  {
    return my_originalsource_node;
  }
  /**
   * sets original source node.
   * @param my_originalsource_node
   */
  public void setMy_originalsource_node(int my_originalsource_node)
  {
    this.my_originalsource_node = my_originalsource_node;
  }
  /**
   * gets the original destination.
   * @return
   */
  public int getMy_originaldest_node()
  {
    return my_originaldest_node;
  }
  /**
   * sets the original destination.
   * @param my_originaldest_node
   */
  public void setMy_originaldest_node(int my_originaldest_node)
  {
    this.my_originaldest_node = my_originaldest_node;
  }
  /**
   * gets remove node message.
   * @return
   */
  public RemoveNodeMessage getMy_remove_node_message()
  {
    return my_remove_node_message;
  }
  /**
   * sets remove node message.
   * @param my_remove_node_message
   */
  public void setMy_remove_node_message(RemoveNodeMessage my_remove_node_message)
  {
    this.my_remove_node_message = my_remove_node_message;
  }
  /**
   * gets method name.
   * @return
   */
  public int getMethod_name()
  {
    return method_name;
  }
  /**
   * sets method name.
   * @param method_name
   */
  public void setMethod_name(int method_name)
  {
    this.method_name = method_name;
  }
  /**
   * gets source node number.
   * @param args
   */
  public int getMy_source_node()
  {
    return my_source_node;
  }
  /**
   * sets source node number.
   * @param my_source_node
   */
  public void setMy_source_node(int my_source_node)
  {
    this.my_source_node = my_source_node;
  }
  /**
   * gets destnode number.
   * @return
   */
  public int getMy_dest_node()
  {
    return my_dest_node;
  }
  /**
   * sets dest node.
   * @param my_dest_node
   */
  public void setMy_dest_node(int my_dest_node)
  {
    this.my_dest_node = my_dest_node;
  }
  /**
   * sets boolean of message status.
   * @return
   */
  public boolean isAnswer_set()
  {
    return answer_set;
  }
  /**
   * sets boolean of message status.
   * @param answer_set
   */
  public void setAnswer_set(boolean answer_set)
  {
    this.answer_set = answer_set;
  }
  /**
   * Fetches the remove node's message.
   * @return the remove node message
   */
  public RemoveNodeMessage getRemoveNodeMessage()
  {
    return my_remove_node_message;
  }
  /**
   * Sets the remove node's message.
   * @param my_remove_node_message stores the remove node's message
   */
  public void setRemoveNodeMessage(final RemoveNodeMessage the_remove_node_message)
  {
    this.my_remove_node_message = the_remove_node_message;
  }
  public boolean isMyRemoveMessage()
  {
    return my_remove_message;
  }
  public void setMyRemoveMessage(final boolean my_remove_message)
  {
    this.my_remove_message = my_remove_message;
  }
  /**
   * to string
   * @return 
   */
  public String toString()
  {
    String string = " The message key - " + this.getHashTableMessage().getkey() +
                    "original source - " + this.getMy_originalsource_node() +
                    " original destination - " + this.getMy_originaldest_node() +
                    " source - " + this.getMy_source_node() +
                    " destination " + this.getMy_dest_node()+ 
                    " method name - " + this.getMethod_name() +
                    " boolean - " + this.isAnswer_set();
    return string;
  }
  /**
   * Returns the token packet.
   * @return : the token packet
   */
  public TokenPacket getMyTokenPacket()
  {
    return my_token_packet;
  }
  /**
   * Sets the token packet.
   * @param the_token_packet : the token packet
   */
  public void setMyTokenPacket(final TokenPacket the_token_packet)
  {
    this.my_token_packet = the_token_packet;
  }
  /**
   * Sets the rebalance updates data for fault tolerance.
   */
  public void setRebUpdate(final RebalanceUpdates data)
  {
    this.faulttolerance = data;
  }
  /**
   * Gets the rebalance updates data.
   * @return RebalanceUpdates
   */
  public RebalanceUpdates getRebUpdate()
  {
    return this.faulttolerance;
  }
}
